# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroupStats do
  @moduledoc """
  Data extracted for a specific group based on certain filter criteria, such as a given time period and/or service filter.

  ## Attributes

  *   `affectedServices` (*type:* `list(GoogleApi.CloudErrorReporting.V1beta1.Model.ServiceContext.t)`, *default:* `nil`) - Service contexts with a non-zero error count for the given filter criteria. This list can be truncated if multiple services are affected. Refer to `num_affected_services` for the total count.
  *   `affectedUsersCount` (*type:* `String.t`, *default:* `nil`) - Approximate number of affected users in the given group that match the filter criteria. Users are distinguished by data in the ErrorContext of the individual error events, such as their login name or their remote IP address in case of HTTP requests. The number of affected users can be zero even if the number of errors is non-zero if no data was provided from which the affected user could be deduced. Users are counted based on data in the request context that was provided in the error report. If more users are implicitly affected, such as due to a crash of the whole service, this is not reflected here.
  *   `count` (*type:* `String.t`, *default:* `nil`) - Approximate total number of events in the given group that match the filter criteria.
  *   `firstSeenTime` (*type:* `DateTime.t`, *default:* `nil`) - Approximate first occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request.
  *   `group` (*type:* `GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroup.t`, *default:* `nil`) - Group data that is independent of the filter criteria.
  *   `lastSeenTime` (*type:* `DateTime.t`, *default:* `nil`) - Approximate last occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request.
  *   `numAffectedServices` (*type:* `integer()`, *default:* `nil`) - The total number of services with a non-zero error count for the given filter criteria.
  *   `representative` (*type:* `GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorEvent.t`, *default:* `nil`) - An arbitrary event that is chosen as representative for the whole group. The representative event is intended to be used as a quick preview for the whole group. Events in the group are usually sufficiently similar to each other such that showing an arbitrary representative provides insight into the characteristics of the group as a whole.
  *   `timedCounts` (*type:* `list(GoogleApi.CloudErrorReporting.V1beta1.Model.TimedCount.t)`, *default:* `nil`) - Approximate number of occurrences over time. Timed counts returned by ListGroups are guaranteed to be: - Inside the requested time interval - Non-overlapping, and - Ordered by ascending time.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :affectedServices =>
            list(GoogleApi.CloudErrorReporting.V1beta1.Model.ServiceContext.t()) | nil,
          :affectedUsersCount => String.t() | nil,
          :count => String.t() | nil,
          :firstSeenTime => DateTime.t() | nil,
          :group => GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroup.t() | nil,
          :lastSeenTime => DateTime.t() | nil,
          :numAffectedServices => integer() | nil,
          :representative => GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorEvent.t() | nil,
          :timedCounts => list(GoogleApi.CloudErrorReporting.V1beta1.Model.TimedCount.t()) | nil
        }

  field(:affectedServices,
    as: GoogleApi.CloudErrorReporting.V1beta1.Model.ServiceContext,
    type: :list
  )

  field(:affectedUsersCount)
  field(:count)
  field(:firstSeenTime, as: DateTime)
  field(:group, as: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroup)
  field(:lastSeenTime, as: DateTime)
  field(:numAffectedServices)
  field(:representative, as: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorEvent)
  field(:timedCounts, as: GoogleApi.CloudErrorReporting.V1beta1.Model.TimedCount, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroupStats do
  def decode(value, options) do
    GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroupStats.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudErrorReporting.V1beta1.Model.ErrorGroupStats do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
